package com.dsdl.chatapp.data;

/**
 * Created by zzg on 2016/7/30.
 */
public class ChatMsg {
    private int _id;
    private String from;//发送方ID
    private String to;//接收方ID
    private String toGroup;//接收方群组id
    private String content;//消息体
    private long time;//服务端分发消息更新时间
    private long sendTime;//客户端发送消息时间
    private int readStatus;//0：未读，1：已读

    private volatile int hashCode;

    @Override
    public int hashCode() {
        int result = hashCode;
        if (result == 0) {
            result = 17;
            if (content != null) {
                result = 3 * result + content.hashCode();
            }
            if (from != null) {
                result = 5 * result + from.hashCode();
            }
            if (to != null) {
                result = 7 * result + to.hashCode();
            }
            if (toGroup != null) {
                result = 9 * result + toGroup.hashCode();
            }
            result = 3 * result + (int) sendTime;
            hashCode = result;
        }
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (this.getClass() != obj.getClass()) {
            return false;
        }
        ChatMsg p = (ChatMsg) obj;
        return this.content.equals(p.content)
                && this.from == p.from
                && this.to == p.to
                && this.toGroup == p.toGroup
                && this.sendTime == p.sendTime
                && this.time == p.time;
    }

    public int get_id() {
        return _id;
    }

    public void set_id(int _id) {
        this._id = _id;
    }

    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

    public String getTo() {
        return to;
    }

    public void setTo(String to) {
        this.to = to;
    }

    public String getToGroup() {
        return toGroup;
    }

    public void setToGroup(String toGroup) {
        this.toGroup = toGroup;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public long getSendTime() {
        return sendTime;
    }

    public void setSendTime(long sendTime) {
        this.sendTime = sendTime;
    }

    public int getReadStatus() {
        return readStatus;
    }

    public void setReadStatus(int readStatus) {
        this.readStatus = readStatus;
    }
}
